package com.lin.blog.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lin.blog.entity.Role;
import com.lin.blog.mapper.RoleMapper;
import com.lin.blog.mapper.RolePermissionVOMapper;
import com.lin.blog.service.IRoleService;
import com.lin.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lin
 * @since 2020-03-08
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Autowired
    private RolePermissionVOMapper rolePermissionVOMapper;

    /**
     * 通过用户名查询所属的角色
     * @param userName
     * @return
     */
    @Override
    public List<Role> getRoleByUserName(String userName) {
        return roleMapper.getRoleByUserName(userName);
    }



    /**
     * 分页获取 RoleList
     * @return
     */
    @Override
    public Result listRole() {
        return Result.success(rolePermissionVOMapper.listRolePermissionVO());
    }
}
